package com.kevin.zhangchao.androidtest;

import android.app.Activity;
import android.content.res.Resources;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MainActivity extends Activity {

    private MultiStateView multiStateView;

    @Bind(R.id.multi_state_view)
    MultiStateView mMultiStateView;

    @Bind(R.id.refresh_layout)
    RefreshLayout mRefreshLayout;

    @Bind(R.id.recycler_view)
    RecyclerView mRecyclerView;

    BusinessListAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        getDrawaleFolderDesisty();
//        multiStateView= (MultiStateView) findViewById(R.id.multi_state_view);
//        multiStateView.setState(MultiStateView.STATE_EMPTY);
        ButterKnife.bind(this);

        init();
        mMultiStateView.setState(MultiStateView.STATE_CONTENT);
    }

    private void init() {

        mRefreshLayout.setEnabled(true);
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh() {
//                refreshPage();
            }
        });


        mAdapter=new BusinessListAdapter();

        List<Business> listItems=new ArrayList<>();
        for (int i=0;i<10;i++){
            Business item=new Business();
            listItems.add(item);
        }

        mAdapter.setItems(listItems);

        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setAdapter(mAdapter);


    }

    @Override
    protected void onResume() {
        super.onResume();


    }

    private void getDisplayInfo(){
        Resources resources=getResources();
        DisplayMetrics displayMetrics=resources.getDisplayMetrics();
        float density=displayMetrics.density;
        int densityDpi=displayMetrics.densityDpi;
        System.out.println("------>density="+density);
        System.out.println("------>densityDpi="+densityDpi);

    }

    private void getDrawaleFolderDesisty(){
        TypedValue typedValue=new TypedValue();
        Resources resources=getResources();
        int id=getResources().getIdentifier("ic_launcher","mipmap",this.getPackageName());
        resources.openRawResource(id,typedValue);
        int density=typedValue.density;
        Log.i("hehe","------>density="+density);
        System.out.println("------>density="+density);
    }
}
